<html>

<head>

<?php

include "../includes/constants.php";
$spells_table = "spells_new";

?>

<title></title>

</head>

<body>

<?php

if ($_GET[npc_spells_id] != "") {
?>

<center>
	<h1>NPC Spell Set</h1>
	<h2><?php echo $_GET[npc_spells_id]; ?>: <?php echo mysql_result(mysql_query("SELECT name FROM npc_spells WHERE id='$_GET[npc_spells_id]'",$db),0); ?></h2>
</center>

<table align="center" border="1">
	<tr>
		<td title="id">id</td>
		<td title="spellid & spell_name">Spell</td>
		<td title="type">Spell Type</td>
		<td title="minlevel">minlevel</td>
		<td title="maxlevel">maxlevel</td>
		<td title="manacost">manacost</td>
		<td title="recast_delay">recast_delay</td>
		<td title="priority">priority</td>
	</tr>

<?php
	$query = "SELECT 
		npc_spells_entries.id, 
		npc_spells_entries.spellid, 
		" . $spells_table . ".name AS spell_name, 
		npc_spells_entries.type, 
		npc_spells_entries.minlevel, 
		npc_spells_entries.maxlevel, 
		npc_spells_entries.manacost, 
		npc_spells_entries.recast_delay, 
		npc_spells_entries.priority 
		FROM npc_spells_entries 
			LEFT JOIN " . $spells_table . "
				ON npc_spells_entries.spellid = " . $spells_table . ".id
		WHERE npc_spells_id='" . $_GET[npc_spells_id] . "'";
	$result = mysql_query($query,$db);
	if ($db_row = mysql_fetch_array($result)) {
		do {
?>
	<tr>
		<td><?php echo $db_row[id]; ?></td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[spellid]; ?>">&nbsp;<input size="30" type="text" name="" value="<?php echo $db_row[spell_name]; ?>"></td>
		<td>
			<select name="type">
				<option>
				<option value="1"<?php if ($db_row[type] == 1) {echo " selected";}; ?>>Nuke
				<option value="2"<?php if ($db_row[type] == 2) {echo " selected";}; ?>>Heal
				<option value="4"<?php if ($db_row[type] == 4) {echo " selected";}; ?>>Root
				<option value="8"<?php if ($db_row[type] == 8) {echo " selected";}; ?>>Buff
				<option value="16"<?php if ($db_row[type] == 16) {echo " selected";}; ?>>Escape
				<option value="32"<?php if ($db_row[type] == 32) {echo " selected";}; ?>>Pet
				<option value="64"<?php if ($db_row[type] == 64) {echo " selected";}; ?>>Lifetap
				<option value="128"<?php if ($db_row[type] == 128) {echo " selected";}; ?>>Snare
				<option value="256"<?php if ($db_row[type] == 256) {echo " selected";}; ?>>DOT
			</select>
		</td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[minlevel]; ?>"></td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[maxlevel]; ?>"></td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[manacost]; ?>"></td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[recast_delay]; ?>"></td>
		<td><input size="1" type="text" name="" value="<?php echo $db_row[priority]; ?>"></td>
	</tr>
<?php
		} while ($db_row = mysql_fetch_array($result));
	} else {
?>
	<tr>
		<td colspan="8" align="center">No results found</td>
	</tr>
<?php
	};

} else {
	echo "<form name=\"NoID\" method=\"GET\" action=\"\">Enter ID: <input type=\"text\" name=\"npc_spells_id\" size=\"2\"><button type=\"submit\">Go</button><br>\n";
};

?>

</body>

</html>